package com.harry.resource.demo.entity;

import java.util.Set;

import javax.persistence.*;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import com.harry.basis.BasePoEntity;

import lombok.*;

@Getter
@Setter
@Entity
public class DemoEntity extends BasePoEntity {

	private static final long serialVersionUID = 1L;

	@Column(nullable = false, insertable = true, updatable = true)
	private String commonColumn;

	@Fetch(FetchMode.JOIN)
	@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	@JoinColumn
	private DemoEntity oneToOne;

	@Fetch(FetchMode.JOIN)
	@ManyToOne(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	@JoinColumn
	private DemoEntity manyToOne;

	@Fetch(FetchMode.JOIN)
	@OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	@JoinColumn
	private Set<DemoEntity> oneToMany;

	@Fetch(FetchMode.JOIN)
	@ManyToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	@JoinTable(joinColumns = @JoinColumn, inverseJoinColumns = @JoinColumn)
	private Set<DemoEntity> manyToMany;
}
